import http from "@/util/request.js";

export default {
    // 根据id获取秒杀活动信息
    getActivityById: (id) => {
        return http({
            url: `/api/seckill/activity/id/${id}`,
            method: 'get'
        })
    },

    // 根据商品名字获取秒杀活动信息
    getActivityByName: (name) => {
        return http({
            url: `/api/seckill/activity/name/${name}`,
            method: 'get'
        })
    },

    // 添加秒杀活动
    addActivity: (data) => {
        return http({
            url: '/api/seckill/activity/add',
            method: 'post',
            data
        })
    },

    // 更新秒杀活动
    updateActivity: (data) => {
        return http({
            url: '/api/seckill/activity/update',
            method: 'put',
            data
        })
    },

    // 删除秒杀活动(软删除)
    deleteActivity: (id) => {
        return http({
            url: `/api/seckill/activity/delete/${id}`,
            method: 'delete'
        })
    },

    // 修改活动状态
    updateStatus: (id) => {
        return http({
            url: `/api/seckill/activity/status/${id}`,
            method: 'put'
        })
    },

    // 获取活动列表
    getActivityList: (data) => {
        return http({
            url: '/api/seckill/activity/list',
            method: 'get',
            params: data
        })
    },

    // 获取活动分页列表
    getActivityPage: (current, size, data) => {
        return http({
            url: '/api/seckill/activity/page',
            method: 'get',
            params: {
                current: current,
                size: size,
                ...data
            }
        })
    }
}